home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 36 / PC Gamer IT CD 36 2-2.iso / VIGDEMO / data1.cab / Assets / scripts / handgrenade.e < prev    next >
Text File  |  1998-09-21  |  6KB  |  766 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447. int Initialize(string type)
  448. {
  449.     global int state;
  450.     global real explodeTime = 3.5;
  451.     global int hitValue = 20;
  452.     global real gEndTime = 0.0;
  453.     global real gSmokeTime = 0.20;
  454.     global int gSmokeTrail = 0;
  455.     global real gExplodeRadius = 30.0;
  456.     global int gBulletCount = 5;
  457.     global real gElasticity = .5;
  458.     global int gContrail = 0;
  459.     global int gPrivileged;
  460.     global int gStartSound = 7;
  461.     global int gProgressSound = 18;
  462.     global int gEndSound = 27;
  463.     global real gMass = 5.0;
  464.     
  465.     Reset("dummy");
  466.     return 0;
  467. }
  468.  
  469. int startsound(string soundname)
  470. {
  471.     gStartSound = GetSoundIndex(soundname);
  472.  
  473. }
  474.  
  475. int endsound(string soundname)
  476. {
  477.     gEndSound = GetSoundIndex(soundname);
  478.  
  479. }
  480.  
  481. int progresssound(string soundname)
  482. {
  483.     gProgressSound = GetSoundIndex(soundname);
  484.  
  485. }
  486.  
  487. int contrail(string str)
  488. {
  489.     gContrail = Str2Int(str);
  490. }
  491.  
  492. int elas(string str)
  493. {
  494.     gElasticity = Str2Real(str);
  495. }
  496.  
  497. int Reset(string dummy)
  498. {
  499.     state = 0;
  500.     SetElas(thisObject,0.0);
  501.     wakeupTime = -1.0;
  502.     SetCollidableProperties(thisObject,0,0);
  503.     SetStyle(thisObject,2);
  504.     gPrivileged = 0;
  505.     SetScale(thisObject,2.0);
  506.     return 0;
  507. }
  508.  
  509. int SetBulletCount(int count)
  510. {
  511.     gBulletCount = count;
  512. }
  513.  
  514. int zombie(string hello)    
  515. {
  516.     SetCollidableProperties(thisObject,0,0);
  517.     SetStyle(thisObject,4);
  518.     SetScale(thisObject,1.0);
  519. }
  520.  
  521. int exploderadius(string str)
  522. {
  523.     gExplodeRadius = Str2Real(str);
  524. }
  525.  
  526. int damage(string str)
  527. {
  528.     hitValue = Str2Int(str);
  529.     return 0;
  530. }
  531.  
  532. int ArmMe(string dummy)
  533. {
  534.     real time ;
  535.     time = GetTime(thisObject);
  536.  
  537.     if (state == 0) 
  538.     {
  539.         state = 5;
  540.  
  541.         SetElas(thisObject,gElasticity);
  542.     
  543.         SetCollidableProperties(thisObject,1,1);
  544.         SetStyle(thisObject,4);  
  545.         PlaySound(thisObject,gStartSound);
  546.         
  547.         gPrivileged = 1;
  548.         SetOldPos(thisObject);
  549.         wakeupTime = time + 0.05;
  550.         gEndTime = time + explodeTime;
  551.         IgnoreCollision(thisObject);
  552.     }
  553.     return 0;
  554. }
  555.  
  556. int ExplodeFulfill(int param)
  557. {
  558.     real time ;
  559.     time = GetTime(thisObject);
  560.     state = 4;
  561.     KillEFX(thisObject,gSmokeTrail);
  562.     gSmokeTrail = 0;
  563.     LaunchEFX(thisObject,2,0);
  564.     Explode(thisObject,hitValue,gExplodeRadius,gMass);
  565.     PlaySound(thisObject,gEndSound);
  566.     MakeDecal(thisObject,1,0);
  567.     SetCollidableProperties(thisObject,0,0);
  568.     SetStyle(thisObject,4);
  569.     wakeupTime = time + 1.0;
  570.     return 0;
  571. }
  572.  
  573. int Explosion(int param)
  574. {
  575.     if (gPrivileged == 1)
  576.     {
  577.         FireSaveInfo(thisObject,hitValue,0,gMass,1);    
  578.  
  579.         ExplodeCommand(thisObject);
  580.     }
  581.  
  582.     return 0;
  583. }
  584.  
  585. int GetMaxAmmo(string dummy)
  586. {
  587.     ReturnValue(thisObject, 1);
  588. }
  589.  
  590. int addammo(string count)
  591. {
  592.     int value = Str2Int(count);
  593.     gBulletCount = gBulletCount + value;
  594. }
  595.  
  596. int AmmoCount(string dum)
  597. {
  598.     ReturnValue(thisObject,gBulletCount);
  599. }
  600.  
  601. int Draw(string ammoCount)
  602. {
  603.     SetStyle(thisObject,2);
  604.     gBulletCount = Str2Int(ammoCount);
  605.     SetScale(thisObject,1.0);
  606. }
  607.  
  608. int Pickup(string dummy)
  609. {
  610.     ReturnValue(thisObject,gBulletCount);
  611.     gBulletCount = 0;    
  612. }
  613.  
  614. int Holster(string dummy)
  615. {
  616.     ReturnValue(thisObject,gBulletCount);
  617.     gBulletCount = 0;        
  618. }
  619.  
  620. int Drop(string dummy)
  621. {
  622.     int returnBullet;
  623.     SetCollidableProperties(thisObject,1,0);
  624.     SetStyle(thisObject,2);
  625.     PlaySound(thisObject,38);
  626.     
  627.     ReturnValue(thisObject,0);
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640. }
  641.  
  642. int Colliders(string dummy) 
  643. {
  644.     int result;
  645.     int value;
  646.     map::iterator ix;
  647.     map objInList;
  648.     result = 0;
  649.     if (state == 0)
  650.     {
  651.         objInList = Collisions(thisObject,0,1,0);
  652.  
  653.         for (ix = begin(objInList) ;ix != end(objInList); ++ix) 
  654.         {
  655.             value = AddObjectTo(first(dereference(ix)),thisObject);
  656.             if (value != 0)
  657.             {
  658.                 PlaySound(thisObject,35);
  659.                 SetScale(thisObject,1.0);
  660.                 break;
  661.             }
  662.         }
  663.  
  664.     }
  665.     else if (state == 2)
  666.     {
  667.  
  668.     objInList = Collisions(thisObject,0,0,0);
  669.  
  670.         for (ix = begin(objInList) ;ix != end(objInList); ++ix)
  671.         {
  672.  
  673.  
  674.             {
  675.                 Explosion(0);
  676.                 break;
  677.             }
  678.         }
  679.     }
  680.     return 0;
  681. }
  682.  
  683. int Collidants(string dummy) 
  684. {
  685.     if (state == 2)
  686.     {
  687.         int result;
  688.         map::iterator ix;
  689.         map objInList;
  690.         result = 0;
  691.         int exploded;
  692.         exploded = 0;
  693.  
  694.         objInList = Collisions(thisObject,1,0,0);
  695.  
  696.         for (ix = begin(objInList) ;ix != end(objInList); ++ix)
  697.         {
  698.  
  699.  
  700.             {
  701.                 Explosion(0);
  702.                 exploded = 1;
  703.                 break;
  704.             }
  705.         }
  706.         if (exploded == 0)
  707.             PlaySound(thisObject,18);
  708.     }
  709.     return 0;
  710. }
  711.  
  712. int TimedEvent(int input)
  713. {
  714.     real time;
  715.     time = GetTime(thisObject);
  716.     if (state == 2)
  717.     {
  718.         if (time > gEndTime)
  719.         {
  720.             wakeupTime = time;
  721.             state = 3;
  722.         }
  723.         else
  724.         {
  725.             if (gContrail == 1)
  726.             {
  727.             
  728.                 if (gSmokeTrail == 0)
  729.                 {
  730.                     gSmokeTrail = LaunchEFX(thisObject,1,0);    
  731.                     SetOldPos(thisObject);
  732.                 }
  733.                 else
  734.                 {
  735.                     MoveEFX(thisObject,gSmokeTrail,1);    
  736.                     SetOldPos(thisObject);
  737.                 }
  738.                 wakeupTime = time + gSmokeTime;
  739.             }
  740.             else
  741.             {
  742.                 wakeupTime = gEndTime;
  743.             }
  744.         }
  745.     }
  746.     else if (state == 3)
  747.     {
  748.         Explosion(0);
  749.     }
  750.     else if (state == 4)
  751.     {
  752.         
  753.         Remove(thisObject);
  754.         wakeupTime = -1.0;
  755.     }
  756.     else if (state == 5)
  757.     {
  758.         state = 2;
  759.         SetStyle(thisObject,0);  
  760.         wakeupTime = time + 0.2;
  761.     }
  762.     else
  763.         wakeupTime = -1.0;
  764.     return 0;
  765. }
  766.